package com.android.zhr.greendao.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.android.zhhr.db.utils.StringConverter;
import java.util.List;

import com.android.zhhr.data.entity.db.DBChapters;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DBCHAPTERS".
*/
public class DBChaptersDao extends AbstractDao<DBChapters, Long> {

    public static final String TABLENAME = "DBCHAPTERS";

    /**
     * Properties of entity DBChapters.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Comic_id = new Property(1, Long.class, "comic_id", false, "COMIC_ID");
        public final static Property Title = new Property(2, String.class, "title", false, "TITLE");
        public final static Property Chapters_title = new Property(3, String.class, "chapters_title", false, "CHAPTERS_TITLE");
        public final static Property Chapters = new Property(4, int.class, "chapters", false, "CHAPTERS");
        public final static Property Num = new Property(5, int.class, "num", false, "NUM");
        public final static Property Current_num = new Property(6, int.class, "current_num", false, "CURRENT_NUM");
        public final static Property Create_time = new Property(7, Long.class, "create_time", false, "CREATE_TIME");
        public final static Property Update_time = new Property(8, Long.class, "update_time", false, "UPDATE_TIME");
        public final static Property StateInte = new Property(9, int.class, "stateInte", false, "STATE_INTE");
        public final static Property Comiclist = new Property(10, String.class, "comiclist", false, "COMICLIST");
        public final static Property Chapters_path = new Property(11, String.class, "chapters_path", false, "CHAPTERS_PATH");
    };

    private final StringConverter comiclistConverter = new StringConverter();
    private final StringConverter chapters_pathConverter = new StringConverter();

    public DBChaptersDao(DaoConfig config) {
        super(config);
    }
    
    public DBChaptersDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"DBCHAPTERS\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"COMIC_ID\" INTEGER," + // 1: comic_id
                "\"TITLE\" TEXT," + // 2: title
                "\"CHAPTERS_TITLE\" TEXT," + // 3: chapters_title
                "\"CHAPTERS\" INTEGER NOT NULL ," + // 4: chapters
                "\"NUM\" INTEGER NOT NULL ," + // 5: num
                "\"CURRENT_NUM\" INTEGER NOT NULL ," + // 6: current_num
                "\"CREATE_TIME\" INTEGER," + // 7: create_time
                "\"UPDATE_TIME\" INTEGER," + // 8: update_time
                "\"STATE_INTE\" INTEGER NOT NULL ," + // 9: stateInte
                "\"COMICLIST\" TEXT," + // 10: comiclist
                "\"CHAPTERS_PATH\" TEXT);"); // 11: chapters_path
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DBCHAPTERS\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, DBChapters entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long comic_id = entity.getComic_id();
        if (comic_id != null) {
            stmt.bindLong(2, comic_id);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(3, title);
        }
 
        String chapters_title = entity.getChapters_title();
        if (chapters_title != null) {
            stmt.bindString(4, chapters_title);
        }
        stmt.bindLong(5, entity.getChapters());
        stmt.bindLong(6, entity.getNum());
        stmt.bindLong(7, entity.getCurrent_num());
 
        Long create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindLong(8, create_time);
        }
 
        Long update_time = entity.getUpdate_time();
        if (update_time != null) {
            stmt.bindLong(9, update_time);
        }
        stmt.bindLong(10, entity.getStateInte());
 
        List comiclist = entity.getComiclist();
        if (comiclist != null) {
            stmt.bindString(11, comiclistConverter.convertToDatabaseValue(comiclist));
        }
 
        List chapters_path = entity.getChapters_path();
        if (chapters_path != null) {
            stmt.bindString(12, chapters_pathConverter.convertToDatabaseValue(chapters_path));
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, DBChapters entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long comic_id = entity.getComic_id();
        if (comic_id != null) {
            stmt.bindLong(2, comic_id);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(3, title);
        }
 
        String chapters_title = entity.getChapters_title();
        if (chapters_title != null) {
            stmt.bindString(4, chapters_title);
        }
        stmt.bindLong(5, entity.getChapters());
        stmt.bindLong(6, entity.getNum());
        stmt.bindLong(7, entity.getCurrent_num());
 
        Long create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindLong(8, create_time);
        }
 
        Long update_time = entity.getUpdate_time();
        if (update_time != null) {
            stmt.bindLong(9, update_time);
        }
        stmt.bindLong(10, entity.getStateInte());
 
        List comiclist = entity.getComiclist();
        if (comiclist != null) {
            stmt.bindString(11, comiclistConverter.convertToDatabaseValue(comiclist));
        }
 
        List chapters_path = entity.getChapters_path();
        if (chapters_path != null) {
            stmt.bindString(12, chapters_pathConverter.convertToDatabaseValue(chapters_path));
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public DBChapters readEntity(Cursor cursor, int offset) {
        DBChapters entity = new DBChapters( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // comic_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // title
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // chapters_title
            cursor.getInt(offset + 4), // chapters
            cursor.getInt(offset + 5), // num
            cursor.getInt(offset + 6), // current_num
            cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7), // create_time
            cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8), // update_time
            cursor.getInt(offset + 9), // stateInte
            cursor.isNull(offset + 10) ? null : comiclistConverter.convertToEntityProperty(cursor.getString(offset + 10)), // comiclist
            cursor.isNull(offset + 11) ? null : chapters_pathConverter.convertToEntityProperty(cursor.getString(offset + 11)) // chapters_path
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, DBChapters entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setComic_id(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setTitle(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setChapters_title(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setChapters(cursor.getInt(offset + 4));
        entity.setNum(cursor.getInt(offset + 5));
        entity.setCurrent_num(cursor.getInt(offset + 6));
        entity.setCreate_time(cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7));
        entity.setUpdate_time(cursor.isNull(offset + 8) ? null : cursor.getLong(offset + 8));
        entity.setStateInte(cursor.getInt(offset + 9));
        entity.setComiclist(cursor.isNull(offset + 10) ? null : comiclistConverter.convertToEntityProperty(cursor.getString(offset + 10)));
        entity.setChapters_path(cursor.isNull(offset + 11) ? null : chapters_pathConverter.convertToEntityProperty(cursor.getString(offset + 11)));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(DBChapters entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(DBChapters entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
